package org.test.mq.common;

import java.util.List;

import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import com.alibaba.rocketmq.common.message.MessageExt;

public class AceMessageListener implements MessageListenerConcurrently{
	
	private IMessageProcessor  messageProcessor;
	
	public ConsumeConcurrentlyStatus consumeMessage(List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
		
		for (MessageExt  msg:msgs) {
			boolean result = messageProcessor.handleMessage(msg);
			if(!result) {
				return ConsumeConcurrentlyStatus.RECONSUME_LATER;
			}
		}
		
		return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
	}

	public IMessageProcessor getMessageProcessor() {
		return messageProcessor;
	}

	public void setMessageProcessor(IMessageProcessor messageProcessor) {
		this.messageProcessor = messageProcessor;
	}
	
}
